package gcontent.config.node.record;

import gcontent.config.Configure;
import gcontent.config.error.ConfigEx;
import gcontent.config.node.SimpleNode;
import gcontent.record.Record;
import gcontent.record.error.RecordEx;

import org.w3c.dom.Node;

public class RecordNode extends SimpleNode {
	
	private Record record = null;
	
	public RecordNode(Node root) throws ConfigEx
	{
		super(root);
	}
	
	public Record getRecord() throws RecordEx
	{
		if(this.record == null) {
			String str;
			
			str = this.node_list.get("name");
			try { 
				record = (Record)Configure.class.getClassLoader().loadClass(str).newInstance();
			} catch(Exception ex) { 
				throw new RecordEx("not class record found it => " + str);
			}
		
			record.loadParameters(this.node_list);
		}
		
		return record;
	}

}
